package VO;
import java.util.*;
import Catalog.*;
public class BookListVO {
	ArrayList<BookVO>  bookslist=new ArrayList<BookVO>();
	String bookID="";
	public BookListVO (ArrayList <BookVO>  blist){
		bookslist = blist;
		init();
	}
	public BookListVO(BookList booklist){
			for(Book b:booklist.getBookList()){
				BookVO bookvo=new BookVO(b);
				bookslist.add(bookvo);
			}
			bookID=booklist.getBookID();
	}
	public BookListVO(String booklistinfo[][]){
		for(String bookinfo[]:booklistinfo){
			BookVO bv=new BookVO(bookinfo);
			bookslist.add(bv);
		}
	}
	public BookListVO(){}
	
	public BookListVO (BookListVO blOfAll,String idList){
		String[] idlist=idList.split("/");
			for(String id:idlist){
				BookVO vo=blOfAll.find(Long.parseLong(id));
				bookslist.add(vo);
			}
	}
	public void init(){
		for(BookVO b:bookslist){
			bookID=bookID+"/"+b.getID();
		}
	}
	public BookVO find(long id){
		BookVO book=null;
		for(BookVO b:bookslist){
			if(b.getID()==id){
				book=b;
				break;
			}
		}
		return book;
	}
	public ArrayList<BookVO> getBooklist (){
		return bookslist;
	}
	public String getblid (){
		return bookID;
	}
	
}

